<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: src/include/lwip/inet_chksum.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('inet__chksum_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">inet_chksum.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="opt_8h.html">lwip/opt.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="pbuf_8h.html">lwip/pbuf.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ip__addr_8h.html">lwip/ip_addr.h</a>&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a0196bd603262882d16b5264b52eafe18"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8h.html#a0196bd603262882d16b5264b52eafe18">SWAP_BYTES_IN_WORD</a>(w)&#160;&#160;&#160;(((w) &amp; 0xff) &lt;&lt; 8) | (((w) &amp; 0xff00) &gt;&gt; 8)</td></tr>
<tr class="separator:a0196bd603262882d16b5264b52eafe18"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6ffe83b4bdd1784a0671ee4778966a01"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8h.html#a6ffe83b4bdd1784a0671ee4778966a01">FOLD_U32T</a>(u)&#160;&#160;&#160;((u32_t)(((u) &gt;&gt; 16) + ((u) &amp; 0x0000ffffUL)))</td></tr>
<tr class="separator:a6ffe83b4bdd1784a0671ee4778966a01"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ab35967a50418358e194e8f80fdc3c865"><td class="memItemLeft" align="right" valign="top">u16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8h.html#ab35967a50418358e194e8f80fdc3c865">inet_chksum_pbuf</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p)</td></tr>
<tr class="separator:ab35967a50418358e194e8f80fdc3c865"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a102544bca5912c78649e25a45a7d0a88"><td class="memItemLeft" align="right" valign="top">u16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8h.html#a102544bca5912c78649e25a45a7d0a88">ip6_chksum_pseudo</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, u8_t proto, u16_t proto_len, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *src, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *dest)</td></tr>
<tr class="separator:a102544bca5912c78649e25a45a7d0a88"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4218e08510fd92c9a699c4e5d9fc17b"><td class="memItemLeft" align="right" valign="top">u16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8h.html#ae4218e08510fd92c9a699c4e5d9fc17b">ip6_chksum_pseudo_partial</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, u8_t proto, u16_t proto_len, u16_t chksum_len, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *src, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *dest)</td></tr>
<tr class="separator:ae4218e08510fd92c9a699c4e5d9fc17b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>IP checksum calculation functions </p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a6ffe83b4bdd1784a0671ee4778966a01"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6ffe83b4bdd1784a0671ee4778966a01">&#9670;&nbsp;</a></span>FOLD_U32T</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define FOLD_U32T</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">u</td><td>)</td>
          <td>&#160;&#160;&#160;((u32_t)(((u) &gt;&gt; 16) + ((u) &amp; 0x0000ffffUL)))</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Split an u32_t in two u16_ts and add them up </p>

</div>
</div>
<a id="a0196bd603262882d16b5264b52eafe18"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0196bd603262882d16b5264b52eafe18">&#9670;&nbsp;</a></span>SWAP_BYTES_IN_WORD</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SWAP_BYTES_IN_WORD</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">w</td><td>)</td>
          <td>&#160;&#160;&#160;(((w) &amp; 0xff) &lt;&lt; 8) | (((w) &amp; 0xff00) &gt;&gt; 8)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Swap the bytes in an u16_t: much like <a class="el" href="def_8c.html#ad637280639de4066392e6b5614fa3e56">lwip_htons()</a> for little-endian </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ab35967a50418358e194e8f80fdc3c865"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab35967a50418358e194e8f80fdc3c865">&#9670;&nbsp;</a></span>inet_chksum_pbuf()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16_t inet_chksum_pbuf </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>pbuf chain over that the checksum should be calculated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>checksum (as u16_t) to be saved directly in the protocol header </dd></dl>

</div>
</div>
<a id="a102544bca5912c78649e25a45a7d0a88"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a102544bca5912c78649e25a45a7d0a88">&#9670;&nbsp;</a></span>ip6_chksum_pseudo()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16_t ip6_chksum_pseudo </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>proto_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. IPv6 addresses are expected to be in network byte order.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>chain of pbufs over that a checksum should be calculated (ip data part) </td></tr>
    <tr><td class="paramname">proto</td><td>ipv6 protocol/next header (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">proto_len</td><td>length of the ipv6 payload (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">src</td><td>source ipv6 address (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">dest</td><td>destination ipv6 address (used for checksum of pseudo header) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>checksum (as u16_t) to be saved directly in the protocol header </dd></dl>

</div>
</div>
<a id="ae4218e08510fd92c9a699c4e5d9fc17b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae4218e08510fd92c9a699c4e5d9fc17b">&#9670;&nbsp;</a></span>ip6_chksum_pseudo_partial()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16_t ip6_chksum_pseudo_partial </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>proto_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>chksum_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. IPv6 addresses are expected to be in network byte order. Will only compute for a portion of the payload.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>chain of pbufs over that a checksum should be calculated (ip data part) </td></tr>
    <tr><td class="paramname">proto</td><td>ipv6 protocol/next header (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">proto_len</td><td>length of the ipv6 payload (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">chksum_len</td><td>number of payload bytes used to compute chksum </td></tr>
    <tr><td class="paramname">src</td><td>source ipv6 address (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">dest</td><td>destination ipv6 address (used for checksum of pseudo header) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>checksum (as u16_t) to be saved directly in the protocol header </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_b0856f6b0d80ccb263b2f415c91f9e17.html">include</a></li><li class="navelem"><a class="el" href="dir_4e6b3cf33a61b6caac9c8ac30c866f37.html">lwip</a></li><li class="navelem"><a class="el" href="inet__chksum_8h.html">inet_chksum.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
